#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->pushButton->setCheckable(true);
    ui->pushButton_2->setCheckable(true);
    ui->pushButton_3->setCheckable(true);
    ui->pushButton_4->setCheckable(true);
    fd = ::open("/dev/Led",O_RDWR);
}

MainWindow::~MainWindow()
{
    ::close(fd);
    delete ui;
}



void MainWindow::on_pushButton_clicked(bool checked)
{
    if(checked)
    {
        ioctl(fd,LED1,LED_ON);
    }else {
        ioctl(fd,LED1,LED_OFF);
    }
}

void MainWindow::on_pushButton_2_clicked(bool checked)
{
    if(checked)
    {
        ioctl(fd,LED2,LED_ON);
    }else {
        ioctl(fd,LED2,LED_OFF);
    }
}

void MainWindow::on_pushButton_3_clicked(bool checked)
{
    if(checked)
    {
        ioctl(fd,LED3,LED_ON);
    }else {
        ioctl(fd,LED3,LED_OFF);
    }
}

void MainWindow::on_pushButton_4_clicked(bool checked)
{
    if(checked)
    {
        ioctl(fd,LED4,LED_ON);
    }else {
        ioctl(fd,LED4,LED_OFF);
    }
}
